package com.billbaijie.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONObject;
import com.billbaijie.model.AutUserInfo;
import com.billbaijie.service.AutUserService;

/**
 * 用户控制类
 * 
 * @author  白杰
 * @version  [2016年3月12日]
 */
@Controller
@RequestMapping(value="AutUserAction")
public class AutUserAction {
	
	@Autowired
	AutUserService autUserService;
	
	/**
	 * 分页查询所有的用户
	 * @param re
	 * @param rp
	 */
	@RequestMapping(value="/findAllAutUser")
	public void findAllAutUser(HttpServletRequest re, HttpServletResponse rp)throws Exception{
		int page=Integer.parseInt(re.getParameter("page"));
		int rows=Integer.parseInt(re.getParameter("rows"));
		Map<String, Object> map = new HashMap<String, Object>();
		Map<String, Object> pageMap = new HashMap<String, Object>();
		pageMap.put("startPage", (page-1)*rows);
		pageMap.put("endPage", rows);
		List<AutUserInfo> u = autUserService.getAll(pageMap);
		int total=autUserService.countAutUser();
		map.put("rows", u);
		map.put("total", total);
		String str=JSONObject.toJSONString(map);
		rp.getWriter().write(str);
	}
}
